<template>
	<view class="content">
		<popup @popupState="popupState" title="服务协议"
			protocolPath='/pages/magic-box/rule/index?url=/api/protocal/platformhelp.html'
			policyPath='/pages/magic-box/rule/index?url=/api/protocal/privacy.html' policyStorageKey="has_read_privacy">
		</popup>
	</view>
</template>

<script>
	import popup from './components/popup.vue';
	import util from "@/common/js/util.js"
	export default {
		components: {
			popup
		},
		data() {
			return {

			}
		},
		onLoad() {

		},
		methods: {
			popupState(state) {
				if (state) {
					// #ifdef APP-PLUS
					plus.runtime.agreePrivacy();
					// #endif
					plus.push.getClientInfoAsync(()=>{
						// console.log("ios start listenPush")
						util.listenPush();
					})
					uni.switchTab({
						url: '/pages/index/index/index'
					})
				} else {
					// #ifdef APP-PLUS
					plus.runtime.disagreePrivacy();
					if (plus.os.name.toLowerCase() === 'android') {
						plus.runtime.quit();
					} else {
						const exitIosAPP = uni.requireNativePlugin('CGF-ExitIosApp');       
						exitIosAPP.exitIosApp();
						// const threadClass = plus.ios.importClass("NSThread");
						// const mainThread = plus.ios.invoke(threadClass, "mainThread");
						// plus.ios.invoke(mainThread, "exit");
						// // ios11
						// plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
					}
					// #endif
				}
			}
		}
	}
</script>

<style>

</style>
